package com.lehecai.core.api.user;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.lehecai.core.api.AbstractApiResultBean;
import com.lehecai.core.lottery.ThirdPartMemberType;
import com.lehecai.core.util.CoreDateUtils;

public class UserNameModifyRecord extends AbstractApiResultBean {
	
	public static final String QUERY_UID = "uid";
	public static final String QUERY_FROM = "from";
	public static final String QUERY_TO = "to";
	public static final String QUERY_TYPE = "type";
	public static final String QUERY_TIME = "timeline";

	
	private long id; //ID
	private long uid; //用户ID
	private String fromStr; //修改前用户名 
	private String toStr; //修改后用户名 
	private ThirdPartMemberType type; //用户类型
	private Date timeline; //修改时间
	
	
	public static UserNameModifyRecord convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		UserNameModifyRecord record = new UserNameModifyRecord();
		record.id = getLong(object, "id");
		record.uid = getLong(object, QUERY_UID);
		record.fromStr = getString(object, QUERY_FROM);
		record.toStr = getString(object, QUERY_TO);
		record.timeline = CoreDateUtils.parseDate(getString(object, QUERY_TIME), CoreDateUtils.DATETIME);
		record.type = ThirdPartMemberType.getItem(getInt(object, QUERY_TYPE));
		return record;
	}
	
	public static List<UserNameModifyRecord> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<UserNameModifyRecord> list = new ArrayList<UserNameModifyRecord>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public void setFromStr(String fromStr) {
		this.fromStr = fromStr;
	}

	public String getFromStr() {
		return fromStr;
	}

	public void setToStr(String toStr) {
		this.toStr = toStr;
	}

	public String getToStr() {
		return toStr;
	}

	public void setTimeline(Date timeline) {
		this.timeline = timeline;
	}

	public Date getTimeline() {
		return timeline;
	}

	public void setType(ThirdPartMemberType type) {
		this.type = type;
	}

	public ThirdPartMemberType getType() {
		return type;
	}

}
